﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using NUnit.Framework;

using Lottery.MediaData.Core;

namespace Lottery.UnitTest.L14 {
    [TestFixture]
    public class Table2 {
        [Test]
        public void Test() {
            var data = new List<SC>();

            // 1
            data.Add(new SC { D = "", Z = "", X = "" });

            // 2
            data.Add(new SC { D = "16", Z = "5", X = "11" });

            // 3
            data.Add(new SC { D = "16", Z = "7", X = "9" });

            // 4
            data.Add(new SC { D = "2", Z = "1", X = "1" });

            // 5
            data.Add(new SC { D = "9", Z = "1", X = "8" });

            // 6
            data.Add(new SC { D = "9", Z = "2", X = "7" });

            // 7
            data.Add(new SC { D = "19", Z = "18", X = "1" });

            // 8
            data.Add(new SC { D = "15", Z = "12", X = "3" });

            // 9
            data.Add(new SC { D = "16", Z = "6", X = "10" });

            // 10
            data.Add(new SC { D = "7", Z = "2", X = "5" });

            // 11
            data.Add(new SC { D = "17", Z = "9", X = "8" });

            // 12
            data.Add(new SC { D = "", Z = "10", X = "" });

            // 13
            data.Add(new SC { D = "19", Z = "14", X = "5" });

            // 14
            data.Add(new SC { D = "15", Z = "14", X = "1" });

            var result = SCHelper.ProcessAllData(data);
            var r = new[] { 
                new { Key = 19, Value = 2},
                new { Key = 18, Value = 1},
                new { Key = 17, Value = 1},
                new { Key = 16, Value = 3},
                new { Key = 15, Value = 2},
                new { Key = 14, Value = 2},
                new { Key = 12, Value = 1},
                new { Key = 11, Value = 1},
                new { Key = 10, Value = 2},
                new { Key = 9, Value = 4},
                new { Key = 8, Value = 2},
                new { Key = 7, Value = 3},
                new { Key = 6, Value = 1},
                new { Key = 5, Value = 3},
                new { Key = 3, Value = 1},
                new { Key = 2, Value = 3},
                new { Key = 1, Value = 4}
            };

            Assert.AreEqual(r.Length, result.Count, "No 0");
            for (int i = 0; i < r.Length; i++) {
                Assert.AreEqual(r[i].Key, result.ElementAt(i).Key, string.Format("No {0}-1", i + 1));
                Assert.AreEqual(r[i].Value, result.ElementAt(i).Value, string.Format("No {0}-2", i + 1));
            }
        }
    }
}
